package com.woniu.microassetserver.mapper;

import com.woniu.microcommonsserver.entity.DevSystemEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DevSystemMapper {

    /**
     * 根据参数进行分页查询
     * @param devSystemEntity
     * @return
     * @author luoyue
     */
    List<DevSystemEntity> findAllByParams(@Param("ds") DevSystemEntity devSystemEntity);


    /**
     *
     * @param id
     * @return
     */
    DevSystemEntity findRPIById(@Param("id") Long id);




    /**
     * 新增资产台账信息
     *
     * @param devSystemEntity
     * @return 受影响的行数
     * @author luoyue
     */
    @Options(
            useGeneratedKeys = true,
            keyProperty = "ds.id"
    )
    @Insert("insert into dev_system " +
            "(system_name,system_number,description,fk_domain_id,attachement,principal_name)" +
            " values(#{ds.systemName},#{ds.systemNumber},#{ds.description},#{ds.fkDomainId},#{ds.attachement},#{ds.principalName},#{ds.principalTelephone},#{ds.principalDuty})")
    int saveDevSystem(@Param("ds") DevSystemEntity devSystemEntity);



    /**
     * 根据ID查询车辆
     *
     * @param id
     * @return
     * @author luoyue
     */
    @Results({



            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property="systemName",column="system_name", javaType = String.class),
            @Result(property="systemNumber",column="system_number", javaType = String.class),
            @Result(property="description",column="description", javaType =String.class),

            @Result(property="fkDomainId", column="fk_domain_id", javaType = Long.class),
            @Result(property="attachement", column="attachement", javaType = String.class),
            @Result(property="principalName" ,column="principal_name", javaType = String.class),

            @Result(property="principalTelephone", column="principal_telephone", javaType =String.class),
            @Result(property="principalDuty" ,column="principal_duty", javaType = String.class),



            /*@Result(property = "customerInfo", column = "fk_customer_id", javaType = AssetsParameterBean.class, one =
            @One(select = "com.woniuxy.creditsystem.common.mapper.CustomerMapper.getOneById", fetchType = FetchType.LAZY)),*/
    })
    @Select("select * from dev_system where id = #{id}")
    DevSystemEntity getOneById(Long id);





    /**
     * 修改资产信息
     *v.
     * @param devSystemEntity
     * @return 受影响的行数
     */
    @Update("<script>" +
            "update dev_system" +
            "<set>" +
            "<if test='ds.systemName != null'>" +
            "system_name = #{ds.systemName}," +
            "</if>" +
            "</set>" +
            "where id = #{ds.id}" +
            "</script>")
    int updateDevSystem(@Param("ds") DevSystemEntity devSystemEntity);


    /**
     * 删除车辆信息
     * @param id
     * @return 受影响的行数
     */

    @Delete("delete from dev_system where id = #{id}")
    int deleteDevSystem(@Param("id")Long id);
}
